#include "check_soa.h"
void queryNameServers(char *domain,char *nsList[],int nsNum)
{
	union{
		HEADER hdr;
		u_char buf[NS_PACKETSZ];

	}query, response;
	int responseLen,queryLen;

	u_char 	*cp;
	struct in_addr saveNsAddr[MAXNS];
	int nsCount;
	struct hostent 	*host;
	int i;
	ns_msg handle;
	ns_rr rr;
	nsCount = _res.nscount;
	for ( i = 0;i<nsCount;i++)
		saveNsAddr[i] = _res.nsaddr_list[i].sin_addr;

	_res.options &= ~(RES_DNSRCH | RES_DEFNAMES);

	for (nsNum--;nsNum >=0;nsNum--){
		_res.options |=RES_RECURSE;
		_res.retry = 4;
		_res.nscount = nsCount ;
		for (i = 0;i<nsCount;i++)
			_res.nsaddr_list[i].sin_addr = saveNsAddr[i];
		host = gethostbyname(nsList[nsNum]);
		if (host ==NULL){
			(void) fprintf(stderr,"There is no address for %s \n",nsList[nsNum]);
			continues;
		}
		(void) memcpy((void *)&_res.nsaddr_list[0].sin_addr,
				(void *）host->h_addr_list[0],(size_t)host->h_length);

		_res.nscount = 1;
		_res.options &= ~RES_RECURSE;
		_res.retry = 2;
	}
}
